package config

/*type HttpProxy struct {
	DomainInfo      string `json:"domain_info" toml:"domain_info"`
	Port            int    `json:"port" toml:"port"`
	IsSSL           bool   `json:"is_ssl" toml:"is_ssl"`
	SSLCertPath     string `json:"ssl_cert_path" toml:"ssl_cert_path"`
	SSLKeyPath      string `json:"ssl_key_path" toml:"ssl_key_path"`
	StaticRoot      string `json:"static_root" toml:"static_root"`
	StaticPath string `json:"static_path" toml:"static_path"`
	BalanceName	string	`json:"balance_name" toml:"balance_name"`
}

type UpstreamServer struct {
	ID        int `json:"id"`
	NetWork   string `json:"net_work" toml:"net_work"`		//http协议
	Addr      string `json:"addr" toml:"addr"`
	Weight    int    `json:"weight" toml:"weight"`         // 0-100 more is better
	TimeOut   int    `json:"timeout" toml:"timeout"`       // 0-60s
	MaxConn   int    `json:"max_conn" toml:"max_conn"`     // 最大链接数
	FailTimes int    `json:"fail_times" toml:"fail_times"` // 最大失败次数，超过失败次数以后，该服务不再尝试
}

//与上游client配置
type UpClient struct {
	UpstreamServer
	Client http.Client
}

type conf struct {
	Http      HttpProxy        `json:"http" toml:"http"`
	Upstreams []UpstreamServer `json:"upstreams" toml:"upstreams"`
}

func (setting *conf) Check() (err error) {
	for i, upstream := range Setting.Upstreams {
		upstream.ID = i
	}
	return
}

var Setting conf

func Init() {
	if _, err := toml.DecodeFile("configs/config.toml", &Setting); err != nil {
		logger.Fatal("配置文件加载失败:", err.Error())
	} else {
		logger.Info("配置文件加载成功")
		Setting.Check()
	}
}*/
